/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('qt-change-service', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model ChangeComponentEnumResponseBody = {
  data?: string(name='Data'),
  errorMsg?: string(name='ErrorMsg'),
  requestId?: string(name='RequestId', description='Id of the request'),
  success?: boolean(name='Success'),
}

model ChangeComponentEnumResponse = {
  headers: map[string]string(name='headers'),
  body: ChangeComponentEnumResponseBody(name='body'),
}

async function changeComponentEnum(): ChangeComponentEnumResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return changeComponentEnumWithOptions(headers, runtime);
}

async function changeComponentEnumWithOptions(headers: map[string]string, runtime: Util.RuntimeOptions): ChangeComponentEnumResponse {
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'ChangeComponentEnum',
    version = '2021-12-01',
    protocol = 'HTTPS',
    pathname = `/scene/changeComponentEnum`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

model CreateScenceRequest {
  dstKnowledge?: {
    condition?: string(name='Condition'),
    conditionList?: [ 
      {
        condition?: string(name='Condition'),
        key?: string(name='Key'),
        value?: string(name='Value'),
      }
    ](name='ConditionList'),
    limit?: long(name='Limit'),
    name?: string(name='Name'),
    offset?: long(name='Offset'),
    sortField?: string(name='SortField'),
    sortType?: string(name='SortType'),
  }(name='DstKnowledge'),
  graphId?: string(name='GraphId'),
  isNonProfit?: boolean(name='IsNonProfit'),
  limit?: long(name='Limit'),
  param?: [ 
    {
      paramCommit?: string(name='ParamCommit'),
      paramKey?: string(name='ParamKey'),
      paramType?: string(name='ParamType'),
    }
  ](name='Param'),
  resultType?: long(name='ResultType'),
  srcKnowledge?: [ 
    {
      knowledge?: {
        name?: string(name='Name'),
      }(name='Knowledge'),
      param?: string(name='Param'),
    }
  ](name='SrcKnowledge'),
  workName?: string(name='WorkName'),
}

model CreateScenceResponseBody = {
  data?: string(name='Data'),
  errorMsg?: string(name='ErrorMsg'),
  requestId?: string(name='RequestId'),
  success?: boolean(name='Success'),
}

model CreateScenceResponse = {
  headers: map[string]string(name='headers'),
  body: CreateScenceResponseBody(name='body'),
}

async function createScence(request: CreateScenceRequest): CreateScenceResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return createScenceWithOptions(request, headers, runtime);
}

async function createScenceWithOptions(request: CreateScenceRequest, headers: map[string]string, runtime: Util.RuntimeOptions): CreateScenceResponse {
  Util.validateModel(request);
  var body : map[string]any= {};
  if (!Util.isUnset(request.dstKnowledge)) {
    body['DstKnowledge'] = request.dstKnowledge;
  }
  if (!Util.isUnset(request.graphId)) {
    body['GraphId'] = request.graphId;
  }
  if (!Util.isUnset(request.isNonProfit)) {
    body['IsNonProfit'] = request.isNonProfit;
  }
  if (!Util.isUnset(request.limit)) {
    body['Limit'] = request.limit;
  }
  if (!Util.isUnset(request.param)) {
    body['Param'] = request.param;
  }
  if (!Util.isUnset(request.resultType)) {
    body['ResultType'] = request.resultType;
  }
  if (!Util.isUnset(request.srcKnowledge)) {
    body['SrcKnowledge'] = request.srcKnowledge;
  }
  if (!Util.isUnset(request.workName)) {
    body['WorkName'] = request.workName;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'CreateScence',
    version = '2021-12-01',
    protocol = 'HTTPS',
    pathname = `/scene/scenario`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

model DeleteScenceRequest {
  id?: long(name='id'),
}

model DeleteScenceResponseBody = {
  data?: string(name='Data'),
  errorMsg?: string(name='ErrorMsg'),
  requestId?: string(name='RequestId'),
  success?: boolean(name='Success'),
}

model DeleteScenceResponse = {
  headers: map[string]string(name='headers'),
  body: DeleteScenceResponseBody(name='body'),
}

async function deleteScence(request: DeleteScenceRequest): DeleteScenceResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return deleteScenceWithOptions(request, headers, runtime);
}

async function deleteScenceWithOptions(request: DeleteScenceRequest, headers: map[string]string, runtime: Util.RuntimeOptions): DeleteScenceResponse {
  Util.validateModel(request);
  var query : map[string]any= {};
  if (!Util.isUnset(request.id)) {
    query['id'] = request.id;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DeleteScence',
    version = '2021-12-01',
    protocol = 'HTTPS',
    pathname = `/scene/scenario`,
    method = 'DELETE',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

model GetScenceResultRequest {
  limit?: long(name='limit'),
  offset?: long(name='offset'),
  taskId?: string(name='taskId'),
}

model GetScenceResultResponseBody = {
  data?: string(name='Data'),
  errorMsg?: string(name='ErrorMsg'),
  requestId?: string(name='RequestId'),
  success?: boolean(name='Success'),
}

model GetScenceResultResponse = {
  headers: map[string]string(name='headers'),
  body: GetScenceResultResponseBody(name='body'),
}

async function getScenceResult(request: GetScenceResultRequest): GetScenceResultResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return getScenceResultWithOptions(request, headers, runtime);
}

async function getScenceResultWithOptions(request: GetScenceResultRequest, headers: map[string]string, runtime: Util.RuntimeOptions): GetScenceResultResponse {
  Util.validateModel(request);
  var query : map[string]any= {};
  if (!Util.isUnset(request.limit)) {
    query['limit'] = request.limit;
  }
  if (!Util.isUnset(request.offset)) {
    query['offset'] = request.offset;
  }
  if (!Util.isUnset(request.taskId)) {
    query['taskId'] = request.taskId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetScenceResult',
    version = '2021-12-01',
    protocol = 'HTTPS',
    pathname = `/scenario/service/result`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

model GetScencesListRequest {
  page?: long(name='page'),
  search?: string(name='search'),
  size?: long(name='size'),
  workName?: string(name='workName'),
}

model GetScencesListResponseBody = {
  data?: string(name='Data'),
  errorMsg?: string(name='ErrorMsg'),
  requestId?: string(name='RequestId'),
  success?: boolean(name='Success'),
}

model GetScencesListResponse = {
  headers: map[string]string(name='headers'),
  body: GetScencesListResponseBody(name='body'),
}

async function getScencesList(request: GetScencesListRequest): GetScencesListResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return getScencesListWithOptions(request, headers, runtime);
}

async function getScencesListWithOptions(request: GetScencesListRequest, headers: map[string]string, runtime: Util.RuntimeOptions): GetScencesListResponse {
  Util.validateModel(request);
  var query : map[string]any= {};
  if (!Util.isUnset(request.page)) {
    query['page'] = request.page;
  }
  if (!Util.isUnset(request.search)) {
    query['search'] = request.search;
  }
  if (!Util.isUnset(request.size)) {
    query['size'] = request.size;
  }
  if (!Util.isUnset(request.workName)) {
    query['workName'] = request.workName;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetScencesList',
    version = '2021-12-01',
    protocol = 'HTTPS',
    pathname = `/scene/list`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

model ModifyScenceRequest {
  creater?: string(name='Creater'),
  gmtCreate?: long(name='GmtCreate'),
  gmtModified?: long(name='GmtModified'),
  id?: long(name='Id'),
  param?: string(name='Param'),
  ruleBody?: string(name='RuleBody'),
  ruleDescribe?: string(name='RuleDescribe'),
  ruleStatus?: string(name='RuleStatus'),
  sceneId?: long(name='SceneId'),
  title?: string(name='Title'),
  workId?: string(name='WorkId'),
  workName?: string(name='WorkName'),
}

model ModifyScenceResponseBody = {
  data?: string(name='Data'),
  errorMsg?: string(name='ErrorMsg'),
  requestId?: string(name='RequestId'),
  success?: boolean(name='Success'),
}

model ModifyScenceResponse = {
  headers: map[string]string(name='headers'),
  body: ModifyScenceResponseBody(name='body'),
}

async function modifyScence(request: ModifyScenceRequest): ModifyScenceResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return modifyScenceWithOptions(request, headers, runtime);
}

async function modifyScenceWithOptions(request: ModifyScenceRequest, headers: map[string]string, runtime: Util.RuntimeOptions): ModifyScenceResponse {
  Util.validateModel(request);
  var body : map[string]any= {};
  if (!Util.isUnset(request.creater)) {
    body['Creater'] = request.creater;
  }
  if (!Util.isUnset(request.gmtCreate)) {
    body['GmtCreate'] = request.gmtCreate;
  }
  if (!Util.isUnset(request.gmtModified)) {
    body['GmtModified'] = request.gmtModified;
  }
  if (!Util.isUnset(request.id)) {
    body['Id'] = request.id;
  }
  if (!Util.isUnset(request.param)) {
    body['Param'] = request.param;
  }
  if (!Util.isUnset(request.ruleBody)) {
    body['RuleBody'] = request.ruleBody;
  }
  if (!Util.isUnset(request.ruleDescribe)) {
    body['RuleDescribe'] = request.ruleDescribe;
  }
  if (!Util.isUnset(request.ruleStatus)) {
    body['RuleStatus'] = request.ruleStatus;
  }
  if (!Util.isUnset(request.sceneId)) {
    body['SceneId'] = request.sceneId;
  }
  if (!Util.isUnset(request.title)) {
    body['Title'] = request.title;
  }
  if (!Util.isUnset(request.workId)) {
    body['WorkId'] = request.workId;
  }
  if (!Util.isUnset(request.workName)) {
    body['WorkName'] = request.workName;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'ModifyScence',
    version = '2021-12-01',
    protocol = 'HTTPS',
    pathname = `/scene/scenario`,
    method = 'PUT',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

model QueryScenceRequest {
  body?: [ 
    {
      id?: long(name='Id'),
      param?: [ 
        {
          paramKey?: string(name='ParamKey'),
          paramType?: string(name='ParamType'),
          paramValue?: string(name='ParamValue'),
        }
      ](name='Param'),
    }
  ](name='body'),
}

model QueryScenceResponseBody = {
  data?: string(name='Data'),
  errorMsg?: string(name='ErrorMsg'),
  requestId?: string(name='RequestId'),
  success?: boolean(name='Success'),
}

model QueryScenceResponse = {
  headers: map[string]string(name='headers'),
  body: QueryScenceResponseBody(name='body'),
}

async function queryScence(request: QueryScenceRequest): QueryScenceResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return queryScenceWithOptions(request, headers, runtime);
}

async function queryScenceWithOptions(request: QueryScenceRequest, headers: map[string]string, runtime: Util.RuntimeOptions): QueryScenceResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = Util.toArray(request.body),
  };
  var params = new OpenApi.Params{
    action = 'QueryScence',
    version = '2021-12-01',
    protocol = 'HTTPS',
    pathname = `/scenario/service/query`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

model StatusScenceRequest {
  taskId?: string(name='taskId'),
}

model StatusScenceResponseBody = {
  data?: string(name='Data'),
  errorMsg?: string(name='ErrorMsg'),
  requestId?: string(name='RequestId'),
  success?: boolean(name='Success'),
}

model StatusScenceResponse = {
  headers: map[string]string(name='headers'),
  body: StatusScenceResponseBody(name='body'),
}

async function statusScence(request: StatusScenceRequest): StatusScenceResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return statusScenceWithOptions(request, headers, runtime);
}

async function statusScenceWithOptions(request: StatusScenceRequest, headers: map[string]string, runtime: Util.RuntimeOptions): StatusScenceResponse {
  Util.validateModel(request);
  var query : map[string]any= {};
  if (!Util.isUnset(request.taskId)) {
    query['taskId'] = request.taskId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'StatusScence',
    version = '2021-12-01',
    protocol = 'HTTPS',
    pathname = `/scenario/service/status`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

